package de.pernpas.stadtfuehrer.entity;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Transient;

import com.google.appengine.api.datastore.Key;

@Entity
@NamedQuery(name = "allUser", query = "SELECT u FROM User u")
public class User {
	
	private String email;
	private String firstname;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Key key;
	@Transient
	private String password;
	private byte[] passwordEncrypted;
	private String pseudonym;
    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
    @Enumerated
    private List<Role> roles;
    private byte[] salt;
    private String surname;
    
    public User() {
		super();
		roles = new ArrayList<Role>();
	}

    public String getEmail() {
        return email;
    }

    public String getFirstname() {
        return firstname;
    }

    public Key getKey() {
		return key;
	}

    public String getPassword() {
		return password;
	}

    public byte[] getPasswordEncrypted() {
		return passwordEncrypted;
	}

	public String getPseudonym() {
        return pseudonym;
    }

	public List<Role> getRoles() {
		return roles;
	}

	public byte[] getSalt() {
		return salt;
	}

	public String getSurname() {
        return surname;
    }

	public void setEmail(String email) {
        this.email = email;
    }

	public void setFirstname(String firstname) {
        this.firstname = firstname;
    }


	public void setKey(Key key) {
		this.key = key;
	}


	public void setPassword(String password) {
		this.password = password;
	}

	public void setPasswordEncrypted(byte[] passwordEncrypted) {
		this.passwordEncrypted = passwordEncrypted;
	}

	public void setPseudonym(String pseudonym) {
        this.pseudonym = pseudonym;
    }

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public void setSalt(byte[] salt) {
		this.salt = salt;
	}

	public void setSurname(String surname) {
        this.surname = surname;
    }
}
